package com.mvp.lt.airlineview.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.TextView;

import androidx.appcompat.widget.AppCompatImageView;

import com.mvp.lt.airlineview.gesture.DefautTouchDetector;
import com.mvp.lt.airlineview.gesture.IDoodle;
import com.mvp.lt.airlineview.gesture.ITouchSelectableItem;
import com.mvp.lt.airlineview.gesture.MyGestureDetector;


/**
 * Created by LiuTao on 2019/11/13 0013 下午 15:50
 * functiona:
 */
public class TouchView extends AppCompatImageView {
    private TextView mTextView;

    public DefautTouchDetector mDefautTouchDetector;

    public TouchView(Context context) {
        super(context);
        init(context);
    }

    public TouchView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TouchView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        MyGestureDetector myGestureDetector = new MyGestureDetector(this, new MyGestureDetector.ISelectionListener() {
            @Override
            public void onSelectedItem(IDoodle doodle, ITouchSelectableItem selectableItem, boolean selected) {

            }

            @Override
            public void onCreateSelectableItem(IDoodle doodle, float x, float y) {

            }
        });
        mDefautTouchDetector = new DefautTouchDetector(getContext(),myGestureDetector);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        boolean consumed = mDefautTouchDetector.onTouchEvent(event); // 由手势识别器处理手势
        if (!consumed) {
            return super.onTouchEvent(event);
        }
        return true;
    }

    public void setTextView(TextView textView) {
        this.mTextView = textView;
    }


}
